#!/usr/bin/env python
# coding=utf-8
import sys

from flask import Blueprint, jsonify


# sys.setdefaultencoding('utf-8')
from server.base.beanret import BeanRet
from server.execute import Execute

service = Blueprint('service', __name__, url_prefix='/service')


@service.route('/executeCmd/<path:cmd>', methods=['GET', 'POST'])
def execute_cmd(cmd):
    """
    执行命令
    :return:返回执行结果
    """
    # 调用执行指令的方法
    result = Execute().execute(cmd)
    if result:
        return BeanRet("0000", True, "执行成功").toJson()
    else:
        return BeanRet("9999", False, "执行失败").toJson()

